package org.afun.oldhand.home.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import org.afun.oldhand.R;
import org.afun.oldhand.base.BaseFragment;
import org.afun.oldhand.home.adapter.HomeRecyclerAdapter;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link HomeFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class HomeFragment extends BaseFragment {
    private View view;
    private RecyclerView fhrv;
    private HomeRecyclerAdapter adapter;


    public static HomeFragment newInstance() {
        HomeFragment fragment = new HomeFragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return initView();
    }

    @Override
    public View initView() {
        if (view == null) {
            view = View.inflate(this.mContext, R.layout.fragment_home, null);
        }
        fhrv=view.findViewById(R.id.fhrv);
//        Toast.makeText(mContext,"init...",Toast.LENGTH_SHORT).show();
        adapter = new HomeRecyclerAdapter(this.mContext);
        fhrv.setAdapter(adapter);
        GridLayoutManager manager = new GridLayoutManager(this.mContext, 1);
        //设置网格布局
        fhrv.setLayoutManager(manager);


        return view;
    }
}